import 'dart:convert';

import 'package:flutter_app/base/net/base_request.dart';

abstract class LpNetAdapter {
  Future<BaseResponse> send<T>(BaseRequest request);
}

// 统一网络层返回格式
class BaseResponse<T> {
  T data;
  BaseRequest request;
  int errorCode;
  String? errorMsg = "";

  BaseResponse(
    this.data,
    this.errorCode,
    this.errorMsg,
    this.request,
  );

  @override
  String toString() {
    if (data is Map) {
      return json.encode(data);
    }
    return data.toString();
  }
}
